package com.gztms.usermgnt.controller;

import com.gztms.usermgnt.pojo.User;
import com.gztms.usermgnt.service.AdminService;
import com.gztms.usermgnt.service.UserService;
import com.gztms.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Zoey
 * @date 2023/4/18 23:57
 * @Description TODO
 **/
@RestController
@RequestMapping("/admin")
public class AdminController {
    @Autowired
    private AdminService adminService;

    @Autowired
    private UserService userService;

    /**
     * 添加管理员
     * @param user
     * @return
     */
    @PostMapping("/addAdmin")
    public ResultUtil addAdmin(@RequestBody User user){
        return userService.addAdmin(user);
    }

    /**
     * 查询所有用户
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/getAllUser")
    public ResultUtil getAllUser(@RequestParam(value = "pageNum") int pageNum, @RequestParam(value = "pageSize") int pageSize) {
        return adminService.getAllUser(pageNum, pageSize);
    }


    @GetMapping("/getAdminList")
    public ResultUtil getAdminList(
            @RequestParam(value = "username", required = false) String username,
            @RequestParam(value = "uid", required = false) String uid,
            @RequestParam(value = "pageNum") int pageNum,
            @RequestParam(value = "pageSize") int pageSize) {
        return adminService.getAdminList(username,uid,pageNum,pageSize);
    }

    



}
